<template>
    <div>
        <el-table :data="songData" stripe highlight-current-row class="table">
            <el-table-column prop="songid" label="id" width="200">
            </el-table-column>
            <el-table-column prop="songName" label="歌曲名" width="200">
            </el-table-column>
            <el-table-column prop="calssifyID" label="分类" width="250">
            </el-table-column>
            <el-table-column prop="regionID" label="地区" width="250">
            </el-table-column>
            <el-table-column label="操作" width="170">
                <template slot-scope="scope">
                    <el-button size="mini" @click="favorites(scope.$index, scope.row)">
                        删除
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>

<script>
export default {
    data(){
        return {
            songData:null
        }
    },
    methods:{
        favorites: function (index, row) {
            this.axios({
                url: "/api/users/songDelete1",
                params: {
                    songsID:row.songsID
                }
            }).then(res => {
                console.log(res.data);
                if (res.data.code == 200) {
                    this.$message({
                        message: '删除成功',
                        type: 'success'
                    });
                } else {
                    this.$message({
                        message: '删除失败',
                        type: 'warning'
                    });
                }
            }).catch(err => {
                console.log("歌曲收藏错误", err);
            })
        },
    },
    created:function(){
        this.axios({
            url:"/api/users/songsAll"
        }).then(res=>{
            console.log(res.data.data.results);
            this.songData = res.data.data.results
        }).catch(err=>{
            console.log("admin用户请求失败");
        })
    }
}
</script>

<style>

</style>